package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Ysorder;
import com.ruoyi.system.service.IYsorderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营收分析Controller
 * 
 * @author ruoyi
 * @date 2025-07-05
 */
@RestController
@RequestMapping("/system/ysorder")
public class YsorderController extends BaseController
{
    @Autowired
    private IYsorderService ysorderService;

    /**
     * 查询营收分析列表
     */
    @PreAuthorize("@ss.hasPermi('system:ysorder:list')")
    @GetMapping("/list")
    public List<Map<String,Object>> list(@Param(value = "csName") String csName, @Param(value = "dtime") String dstime)
    {
//        startPage();

        List<Map<String,Object>> list = ysorderService.selectYsorderList(csName,dstime);
        System.out.println(csName+""+dstime);
        return list;
    }

    /**
     * 导出营收分析列表
     */
//    @PreAuthorize("@ss.hasPermi('system:ysorder:export')")
//    @Log(title = "营收分析", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, @Param(value = "csName") String csName,@Param(value = "oTime") String oTime)
//    {
//        List<Ysorder> list = ysorderService.selectYsorderList(csName,oTime);
//        ExcelUtil<String,String> util = new ExcelUtil<Ysorder>(csName,oTime);
//        util.exportExcel(response, list, "营收分析数据");
//    }

    /**
     * 获取营收分析详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ysorder:query')")
    @GetMapping(value = "/{oId}")
    public AjaxResult getInfo(@PathVariable("oId") Integer oId)
    {
        return success(ysorderService.selectYsorderByOId(oId));
    }

    /**
     * 新增营收分析
     */
    @PreAuthorize("@ss.hasPermi('system:ysorder:add')")
    @Log(title = "营收分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ysorder ysorder)
    {
        return toAjax(ysorderService.insertYsorder(ysorder));
    }

    /**
     * 修改营收分析
     */
    @PreAuthorize("@ss.hasPermi('system:ysorder:edit')")
    @Log(title = "营收分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ysorder ysorder)
    {
        return toAjax(ysorderService.updateYsorder(ysorder));
    }

    /**
     * 删除营收分析
     */
    @PreAuthorize("@ss.hasPermi('system:ysorder:remove')")
    @Log(title = "营收分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oIds}")
    public AjaxResult remove(@PathVariable Integer[] oIds)
    {
        return toAjax(ysorderService.deleteYsorderByOIds(oIds));
    }
}
